using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System;
using YouYouFramework;
using Cysharp.Threading.Tasks;


public class GameUtil
{
    /// <summary>
    /// 加载FBX嵌入的所有动画
    /// </summary>
    public static AnimationClip[] LoadInitRoleAnimationsByFBX(string assetFullPath)
    {
        return GameEntry.Loader.LoadResourcesAll<AnimationClip>(assetFullPath);
    }

    /// <summary>
    /// 获取路径的最后名称
    /// </summary>
    public static string GetLastPathName(string path)
    {
        if (path.IndexOf('/') == -1)
        {
            return path;
        }
        return path.Substring(path.LastIndexOf('/') + 1);
    }

    /// <summary>
    /// 加载Prefab并克隆
    /// </summary>
    public static GameObject LoadPrefabClone(string assetFullPath, Transform parent = null)
    {
        GameObject prefab = GameEntry.Loader.LoadResources<GameObject>(assetFullPath);
        GameObject obj = UnityEngine.Object.Instantiate(prefab, parent);
        return obj;
    }
    public static async UniTask<GameObject> LoadPrefabCloneAsync(string assetFullPath, Transform parent = null)
    {
        GameObject prefab = await GameEntry.Loader.LoadResourcesAsync<GameObject>(assetFullPath);
        GameObject obj = UnityEngine.Object.Instantiate(prefab, parent);
        return obj;
    }
}